package com.bzy.service;

import com.bzy.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;
import java.util.List;

/**
 * @ Author     : Bzy.
 * @ Date       : 2020/12/28 -- 18:37
 * @ Version:     $ 1.0
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${user.rest.url}")
    private String userurl;


    @Override
    public List<User> getAllUser() {
        User[] users=restTemplate.getForObject(userurl, User[].class);
        return Arrays.asList(users);
    }
}
